if (NOT WIN32)
	message(STATUS "Nothing to be fixed")
else()


	# message(STATUS ${PATH})

	file(GLOB PACKAGES "${PATH}/*")
	list(REMOVE_ITEM PACKAGES "${PATH}/.renv")

	# message(STATUS ${PACKAGES})

	foreach(PACKAGE_PATH ${PACKAGES})

		# message(STATUS "PACKAGE_PATH: ${PACKAGE_PATH}")
		
		execute_process(
			WORKING_DIRECTORY ${PATH}
			COMMAND powershell -command "(Get-Item -Path ${PACKAGE_PATH} -Force).Target"
			OUTPUT_VARIABLE RENV_PATH_OF_PACKAGE
			OUTPUT_STRIP_TRAILING_WHITESPACE)

		# message(STATUS ${RENV_PATH_OF_PACKAGE})

		cmake_path(SET RENV_PATH_OF_PACKAGE_CMAKE_PATH NORMALIZE ${RENV_PATH_OF_PACKAGE})
		cmake_path(IS_RELATIVE RENV_PATH_OF_PACKAGE_CMAKE_PATH RENV_PATH_IS_ALREADY_RELATIVE)

		if(RENV_PATH_OF_PACKAGE AND (NOT RENV_PATH_IS_ALREADY_RELATIVE))

			# message(STATUS "RENV_PATH_OF_PACKAGE: ${RENV_PATH_OF_PACKAGE}")


			string(LENGTH "${PATH}/" PATH_LENGTH)

			string(LENGTH "${PACKAGE_PATH}/" PACKAGE_PATH_LENGTH)

			string(SUBSTRING "${PACKAGE_PATH}" "${PATH_LENGTH}" "-1" PACKAGE_NAME)
			# message(STATUS "PACKAGE_NAME: ${PACKAGE_NAME}")

			message(CHECK_START "Replacing an absolute symlink path with a relative symlink for ${PACKAGE_NAME}")

			string(LENGTH ${MODULES_BINARY_PATH} MODULE_BINARY_PATH_LENGTH)

			string(SUBSTRING "${RENV_PATH_OF_PACKAGE}" "${MODULE_BINARY_PATH_LENGTH}" "-1" PACKAGE_DESTINATION)

			set(PACKAGE_DESTINATION "..${PACKAGE_DESTINATION}")
			# message(STATUS "PACKAGE_DESTINATION: ${PACKAGE_DESTINATION}")

			cmake_path(SET PACKAGE_DESTINATION_PATH NORMALIZE ${PACKAGE_DESTINATION})
			# message(STATUS "PACKAGE_DESTINATION_PATH: ${PACKAGE_DESTINATION_PATH}")
			cmake_path(NATIVE_PATH PACKAGE_DESTINATION_PATH NORMALIZE PACKAGE_DESTINATION_NATIVE_PATH)
			# message(STATUS "PACKAGE_DESTINATION_NATIVE_PATH: ${PACKAGE_DESTINATION_NATIVE_PATH}")

			# if(EXISTS "${PACKAGE_DESTINATION_NATIVE_PATH}")

				execute_process(WORKING_DIRECTORY ${PATH}
					COMMAND ${CMAKE_COMMAND} -E rm ${PACKAGE_PATH})

				execute_process(
					WORKING_DIRECTORY ${PATH}
					COMMAND
					${CMAKE_COMMAND} -E create_symlink ${PACKAGE_DESTINATION_NATIVE_PATH} ${PACKAGE_NAME})


			message(CHECK_PASS "done")
			# endif()
		
		endif()

	endforeach()

endif()